<!DOCTYPE HTML>
<title>Test seeking by very small increments.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var seekedEventCount = 0;
    var increment = 0;
    var video = document.querySelector("video");

    video.currentTime = seekIncrement();

    video.onseeked = t.step_func(function() {
        if (++seekedEventCount == 8) {
            t.done();
            return;
        }
        video.currentTime += seekIncrement();
    });

    function seekIncrement() {
        // We want to verify that seeking by an increment smaller than the test movie's
        // time scale(the smallest unit of time in that file) succeeds. test.mp4 has a time
        // scale of 1 millisecond, so start with that and decrease by half each time.
        if (!increment)
            increment = 0.001;
        else
            increment /= 2;
        return increment;
    }

    video.onseeking = t.step_func(function() {});
    video.onplay = t.step_func(function() {});
    video.onpause = t.step_func(function() {});

    video.src = "content/test.ogv";
});
</script>